<template>
  <div class="container">
    <NavBar title="门诊" :left-arrow="false" />
    <div class="jiuBox">
      <van-row>
        <van-col span="8" v-for="(item, index) in stateList" :key="index">
          <div class="itemBox">
            <div class="liBox" @click="handleToIntegralPage(item)">
              <van-image
                width="30px"
                height="30px"
                fit="contain"
                :src="item.icon"
              />
              <div class="title">
                {{ item.title }}
              </div>
            </div>
          </div>
        </van-col>
      </van-row>
    </div>
    <!-- 底部导航 -->
    <tab-bar></tab-bar>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from "vue";
import { getAccessToken, login } from "@/api/index.js";
import { useRouter } from "vue-router";
import { Image as VanImage } from "vant";
import { getToken } from "@/utils/auth";

const router = useRouter();
const getAccessTokenData = ref();

const stateList = reactive([
  {
    title: "门诊医生站",
    path: "/doctorStation",
    icon: new URL("@/assets/images/menzhen/yishenzhang.png", import.meta.url)
      .href,
  },
  {
    title: "门诊日志",
    path: "/doctorStation",
    icon: new URL("@/assets/images/menzhen/menzhenrizhi.png", import.meta.url)
      .href,
  },
  {
    title: "门诊皮试",
    path: "/doctorStation",
    icon: new URL("@/assets/images/menzhen/pishi.png", import.meta.url).href,
  },
  {
    title: "门诊输液",
    path: "/doctorStation",
    icon: new URL("@/assets/images/menzhen/shuye.png", import.meta.url).href,
  },
  {
    title: "输液日志",
    path: "/doctorStation",
    icon: new URL("@/assets/images/menzhen/shuyerizhi.png", import.meta.url)
      .href,
  },
]);

onMounted(() => {
  let url = "http://10.150.15.122:3200/";
  let encodeUrl = encodeURIComponent(url);
  console.log(encodeUrl);

  // http://100.22.10.39/connect/oauth2/authorize?appid=wwa16dcd8c5531a37b&redirect_uri=http%3A%2F%2F10.150.15.122%3A3200%2F&response_type=code&scope=snsapi_base&agentid=1000033&state=STATE#wechat_redirect
  // loginAction();
});

const loginAction = async () => {
  const res = await login({
    username: "admin",
    password: "123456",
    rememberMe: true,
  });
  console.log("res:", res);
};

const getAccessTokenAction = async () => {
  const res = await getAccessToken(
    "wwa16dcd8c5531a37b",
    "-CQI7QZIZhGZyFrEAf_7pSoillLsq9SJOcNMtB96XyU"
  );
  getAccessTokenData.value = res;
  console.log("res:", res);
};

const handleToIntegralPage = (row) => {
  router.push(row.path);
};
</script>

<style lang="less" scoped>
.jiuBox {
  width: 100%;
  padding: 15px;
  box-sizing: border-box;
  .itemBox {
    height: 100px;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;

    .liBox {
      height: 100%;
      width: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      font-size: 14px;
      font-weight: bold;
      // border: 2px solid #00bfc6ed; /* 2像素宽的红色实线边框 */
      border-radius: 10px;
      box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2);
      .title {
        margin-top: 10px;
      }
    }
  }
}
</style>
